package org.nanotek.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.ejb.TransactionManagement;
import javax.ejb.TransactionManagementType;
import javax.interceptor.Interceptors;

import org.nanotek.beans.ArtistName;
import org.nanotek.dao.ArtistDAO;
import org.nanotek.dao.mapper.ArtistMapper;
import org.nanotek.dao.mapper.ArtistNameMapMapper;
import org.nanotek.repository.ArtistNameRepository;
import org.nanotek.service.ArtistService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ejb.interceptor.SpringBeanAutowiringInterceptor;

@Stateless(name="ArtistService" , mappedName="ArtistService")
@TransactionManagement(TransactionManagementType.CONTAINER)
@SuppressWarnings("unchecked")
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class ArtistServiceImpl implements ArtistService {

	
	public ArtistServiceImpl() 
	{ 
		System.out.println("This is the bean constructor on WEB");
	}
	@Override
	public ArtistName findArtistById(Long code) {
//		return artistDAO.find(code);
		return null;
	}

	@Override
	public <T extends ArtistName> List<T> loadArtistList(Integer startRecord, Integer numRecords) {
//		return artistDAO.listRecords(startRecord, numRecords).stream().map(new ArtistMapper<T>()).collect(Collectors.toList());
		return null;
	}
	
	
	@Override
	public List<Map<String, ?>> prepareReportResult(List<?> artists) {
		List<ArtistName> innerList = (List<ArtistName>) artists;
		return innerList.stream().map(new ArtistNameMapMapper()).collect(Collectors.toList());
	}
//(Function<?, ? extends R>) new ArtistNameHashMapper()).collect(Collectors.toList());

	@Override
	public List<?> findArtistByName(String value) {
		return new ArrayList<>();//artistNameRepository.findByNameLike(value);
	}
}
